<template>
  <div style="width: 95vw; height: 92vh; margin: 7px">
    <iframe :src="cockpiturl" width="100%" height="100%"></iframe>
  </div>
</template>

<script>
import { reactive, toRefs, onBeforeMount, onMounted } from 'vue';
import axios from 'axios'
import { GM_SM4Encrypt } from '../../utils/sm4Import'
export default {
  name: '',
  components: {},
  props: [],
  // beforeRouteEnter(to,from){

  // },
  setup() {
    const state = reactive({
      cockpiturl: '',
    });
    onBeforeMount(() => {
      // console.log('2.组件挂载页面之前执行----onBeforeMount')
    });
    onMounted(async () => {
      let encryptFlagData = GM_SM4Encrypt("Anchor120...")
      await axios.post(`/cockpit/Home/UserLoginByInfo?lgFlag=${encryptFlagData}`)
        .then(res => {
          // console.log(res)
          if (res != null && res != "") {
            state.cockpiturl = `/cockpit${res.data}&Flag=${encryptFlagData}`
            console.log(state.cockpiturl);
          }
        }).catch(err => {
          console.log(err)
        })
      // console.log('3.-组件挂载到页面之后执行-------onMounted')
    });
    const refState = toRefs(state);
    return {
      ...refState,
    };
  },
};
</script>
<style scoped></style>